package terra.definitions;

import java.util.HashMap;

public class Def {

	public int id;
	public String name;
	
	public HashMap<String,String> properties = new HashMap<String,String>();
	
	public int getIntProperty(String name)	{
		if (properties.containsKey(name))
			return Integer.parseInt(properties.get(name));
		return 0;
	}
	
	public float getFloatProperty(String name)	{
		if (properties.containsKey(name))
			return Float.parseFloat(properties.get(name));
		return 0;
	}
	
	public boolean getBoolProperty(String name)	{
		if (properties.containsKey(name))
			return Boolean.parseBoolean(properties.get(name));
		return false;
	}
	
	public byte getByteProperty(String name)	{
		if (properties.containsKey(name))
			return Byte.parseByte(properties.get(name));
		return 0;
	}
	
	public String getStringProperty(String name)	{
		if (properties.containsKey(name))
			return properties.get(name);
		return "";
	}
	
	public short getShortProperty(String name) {
		if (properties.containsKey(name))
			return Short.parseShort(properties.get(name));
		return 0;
	}

	public long getLongProperty(String name) {
		if (properties.containsKey(name))
			return Long.parseLong(properties.get(name));
		return 0;
	}
	
	public void addProperty(String name, String value)	{
		properties.put(name, value);
	}
}
